<!-- 车辆详情页面-->
<template>
	<view class="main-box">
		<view class="main-box-item">
			<view class="box-info-label">
				车牌号
			</view>
			<view class="box-info-value">
				{{item.code}}
			</view>
			<!-- 审批状态 -->
			<view class="status" :style="getCarApproveState(item.state).stylefill">
				{{getCarApproveState(item.state).value}}
			</view>
		</view>
		<view class="main-box-item">
			<view class="box-info-label">
				车牌颜色
			</view>
			<view class="box-info-value">
				{{item.color}}
			</view>
		</view>
		<view class="main-box-item" v-if="!!item.trailercode">
			<view class="box-info-label">
				挂车号
			</view>
			<view class="box-info-value">
				{{item.trailercode==null?'':item.trailercode}}
			</view>
		</view>
		<view class="main-box-item">
			<view class="box-info-label">
				所属企业
			</view>
			<view class="box-info-value">
				{{item.enterprise}}
			</view>
		</view>
		<view class="main-box-item">
			<view class="box-info-label">
				行驶证号
			</view>
			<view class="box-info-value">
				{{item.drivingpermit}}
			</view>
		</view>
		<view class="main-box-item2">
			<view class="box-info-label">
				行驶证照片
			</view>
			<view class="box-info-value">
				<view class="img-box">
					<view class="img-item" v-for="(item, index) in permitImgList" :key="index">
						<image class="img" @click="imgInfo(1,index)" :src="item.path" mode="aspectFill">
						</image>
					</view>
				</view>
			</view>
		</view>
		<view class="main-box-item2">
			<view class="box-info-label">
				车辆照片
			</view>
			<view class="box-info-value">
				<view class="img-box">
					<view class="img-item" v-for="(item, index) in carImgList" :key="index">
						<image class="img" @click="imgInfo(2,index)" :src="item.path" mode="aspectFill">
						</image>
					</view>
				</view>
			</view>
		</view>
		<view class="main-box-item2">
			<view class="box-info-label">
				资质照片
			</view>
			<view class="box-info-value">
				<view class="img-box">
					<view class="img-item" v-for="(item, index) in qualificationList" :key="index">
						<image class="img" @click="imgInfo(3,index)" :src="item.path" mode="aspectFill">
						</image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		Platform,
	} from '@/static/config.js';
	import {
		GetCarApproveState
	} from "@/common/util.js"
	import {
		GetFirstImgFormat
	} from "@/common/util-file.js";
	export default {
		props: ['item'],
		components: {},

		data() {
			return {
				permitImgList: [], // 行驶证图片信息
				carImgList: [], // 车辆图片信息
				qualificationList: [], // 资质图片
			}
		},
		mounted() {
			this.initImge();
		},
		onLoad(options) {

		},
		methods: {
			getCarApproveState(val) {
				return GetCarApproveState(val);
			},
			// 照片处理
			initImge() {
				let _self = this;
				_self.permitImgList = [];
				_self.carImgList = [];
				_self.qualificationList = [];
				// 行驶证照片
				if ((!!_self.item.drivingpermitimage) && (!!_self.item.drivingpermitimagepath)) {
					let permitImgListTemp = _self.item.drivingpermitimage.split(','); // 与path一一对应
					let permitImgListPathTemp = _self.item.drivingpermitimagepath.split(',');
					permitImgListPathTemp.forEach((item, index) => {
						_self.permitImgList.push({
							"id": permitImgListTemp[index],
							"path": item
						});
					})
				}
				// 车辆照片
				if ((!!_self.item.carimage) && (!!_self.item.carimagepath)) {
					let carImgListTemp = _self.item.carimage.split(','); // 与path一一对应
					let carImgListPathTemp = _self.item.carimagepath.split(',');
					carImgListPathTemp.forEach((item, index) => {
						_self.carImgList.push({
							"id": carImgListTemp[index],
							"path": item
						});
					})
				}
				// 资质照片
				if ((!!_self.item.qualification) && (!!_self.item.qualificationimagepath)) {
					_self.qfIsShow = true;
					let qualificationListTemp = _self.item.qualification.split(','); // 与path一一对应
					let qualificationListPathTemp = _self.item.qualificationimagepath.split(',');
					qualificationListPathTemp.forEach((item, index) => {
						_self.qualificationList.push({
							"id": qualificationListTemp[index],
							"path": item
						});
					})
				} else {
					_self.qfIsShow = false;
				}
			},
			imgInfo(v, i) {
				let tempList = [];
				if (v == 1) {
					// tempList = [];
					this.permitImgList.forEach(img => {
						tempList.push(img.path);
					});
				}
				if (v == 2) {
					// tempList = [];
					this.carImgList.forEach(img => {
						tempList.push(img.path);
					});
				}
				if (v == 3) {
					// tempList = [];
					this.qualificationList.forEach(img => {
						tempList.push(img.path);
					});
				}
				// **************** 预览图片 ****************
				uni.previewImage({
					current: i, //为当前显示图片的链接/索引值，不填或填写的值无效则为 urls 的第一张
					loop: false, //是否可循环预览，默认值为 false
					urls: tempList, //需要预览的图片链接列表
					indicator: 'default' //图片指示器样式，可取值："default" - 底部圆点指示器； "number" - 顶部数字指示器； "none" - 不显示指示器。
					// longPressActions:长按图片显示操作菜单，如不填默认为保存相册
					// success
					// fail
					// complete
				});
			},

		},
	}
</script>

<style lang='scss' scoped>
	.main-box {
		/* flex: 1; */
		overflow: scroll;
		background: #e9e9e9;
		height: 100%;
		padding-top: 10rpx;

		.main-box-item {
			display: flex;
			align-items: center;
			height: 50px;
			background: #FFFFFF;
			/* box-shadow: 0px 2px 5px #F0F0F0; */
			/* border-radius: 4px; */
			vertical-align: middle;
			padding: 0px 10px;
			border-bottom-color: #E6E6E6;
			border-bottom-style: solid;
			border-bottom-width: 0.5px;

			.box-info-label {
				margin: 0 10px;
				font-size: 14px;
				font-weight: 500;
			}

			.box-info-value {
				margin-left: 10px;
				font-size: 14px;
				color: #B5B5B5;
				flex: 1;
				display: flex;

				.img {
					height: 38rpx;
					width: 38rpx;
					margin-left: 20rpx;
				}
			}

			.status {
				float: right;
				font-size: 22rpx;
				text-align: center;
				broder: 2rpx;
				border-width: 1rpx;
				border-style: solid;
				height: 38rpx;
				width: 80rpx;
				border-radius: 10rpx;
			}
		}

		.main-box-item2 {
			display: flex;
			flex-direction: column;
			/* align-items: center; */
			/* height: 50px; */
			background: #FFFFFF;
			/* box-shadow: 0px 2px 5px #F0F0F0; */
			/* border-radius: 4px; */
			vertical-align: middle;
			padding: 0px 10px;
			border-bottom-color: #E6E6E6;
			border-bottom-style: solid;
			border-bottom-width: 0.5px;

			.box-info-label {
				margin: 0 10px;
				font-size: 14px;
				font-weight: 500;
			}

			.box-info-value {
				margin-left: 10px;
				font-size: 14px;
				color: #B5B5B5;
				flex: 1;
				display: flex;

				.img-box {
					display: flex;
					width: 100%;
					padding: 0 40rpx;
					padding-left: 10rpx;
					flex-direction: row;
					flex-wrap: wrap;

					.img-item {
						/* width:210rpx;
					height:210rpx; */
						width: 150rpx;
						height: 150rpx;
						border-radius: 16rpx;
						position: relative;
						/* padding: 9rpx 0; */
						margin: 5rpx 10rpx;

						.img {
							width: 150rpx;
							height: 150rpx;
							border-radius: 16rpx;
						}
					}
				}
			}
		}
	}
</style>
